﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using QD.Tools;
using QD.LopPlat.UI.Code.DbContent;
using QD.SQLHelper;

namespace QD.LopPlat.UI
{
    public partial class QDLicenceValidMag : BaseForm
    {
        public QDLicenceValidMag()
        {
            InitializeComponent();
        }

        private void QDLicenceValidMag_Load(object sender, EventArgs e)
        {
            this.grid.InitGrid();
            this.grid.RowTemplate.ContextMenuStrip = this.contextMenuStrip1;

            this.KeyPreview = true;
            this.KeyDown += QDLicenceValidMag_KeyDown;

            this.message.Text = "状态代码： 1正常 10000未授权 10001已过期";
        }

        private void QDLicenceValidMag_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                搜索_Click(sender, e);
            }
        }

        private void 搜索_Click(object sender, EventArgs e)
        {
            try
            {
                DbQfDevPlat db = new DbQfDevPlat();

                string sql = "select top 1000 * from QDLicenceValid order by VerifyDate desc";
                DataTable dt = db.Query(sql);

                this.grid.DataSource = dt;
            }
            catch (Exception ex)
            {
                Tools.PromptHelper.Prompt(ex);
            }
        }

        private void 复制单元格ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            this.grid.CopyFirstSelectedCellValue();
        }

        private void 复制所有选中单元格ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            this.grid.CopySelectedCellsValue();
        }
    }
}